package com.agileplex.products.acc.commands;

import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;


/**
 * Parameters
 *
 * @creator Rui Tang
 * @date 2008-06-20
 *
 * @LastChanged
 * @LastChangedBy $LastChangedBy: tangrui@agileplex.com $
 * @LastChangedDate $LastChangedDate: 2008-06-22 16:08:49 +0000 (Sun, 22 Jun 2008) $
 * @LastChangedRevision $LastChangedRevision: 7 $
 */
public class Parameters {

    private List<Parameter> params = new ArrayList<Parameter>();

    public void add(Parameter param) {
        this.params.add(param);
    }

    public org.apache.commons.cli.Options toCliOptions() {
        org.apache.commons.cli.Options cliOpts = new org.apache.commons.cli.Options();

        for (Iterator<Parameter> pIt = params.iterator(); pIt.hasNext(); ) {
            Parameter p = pIt.next();
            for (Iterator<Option> oIt = p.getOptions().iterator(); oIt.hasNext(); ) {
                Option opt = oIt.next();
                cliOpts.addOption(opt.getAbbr(), opt.getName(), true, "");
            }
        }

        return cliOpts;
    }

}
